Integrand size = 13, antiderivative size = 61 \[ \int \frac {\tan ^2(x)}{a+b \cos (x)} \, dx=-\frac {2 \sqrt {a-b} \sqrt {a+b} \arctan \left (\frac {\sqrt {a-b} \tan \left (\frac {x}{2}\right )}{\sqrt {a+b}}\right )}{a^2}-\frac {b \text {arctanh}(\sin (x))}{a^2}+\frac {\tan (x)}{a} \]
-b*arctanh(sin(x))/a^2-2*arctan((a-b)^(1/2)*tan(1/2*x)/(a+b)^(1/2))*(a-b)^ (1/2)*(a+b)^(1/2)/a^2+tan(x)/a
Time = 0.14 (sec) , antiderivative size = 85, normalized size of antiderivative = 1.39 \[ \int \frac {\tan ^2(x)}{a+b \cos (x)} \, dx=\frac {-2 \sqrt {-a^2+b^2} \text {arctanh}\left (\frac {(a-b) \tan \left (\frac {x}{2}\right )}{\sqrt {-a^2+b^2}}\right )+b \left (\log \left (\cos \left (\frac {x}{2}\right )-\sin \left (\frac {x}{2}\right )\right )-\log \left (\cos \left (\frac {x}{2}\right )+\sin \left (\frac {x}{2}\right )\right )\right )+a \tan (x)}{a^2} \]
(-2*Sqrt[-a^2 + b^2]*ArcTanh[((a - b)*Tan[x/2])/Sqrt[-a^2 + b^2]] + b*(Log [Cos[x/2] - Sin[x/2]] - Log[Cos[x/2] + Sin[x/2]]) + a*Tan[x])/a^2
Time = 0.58 (sec) , antiderivative size = 75, normalized size of antiderivative = 1.23, number of steps used = 12, number of rules used = 11, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.846, Rules used = {3042, 3202, 3042, 3535, 25, 3042, 3480, 3042, 3138, 218, 4257}
Below are the steps used by Rubi to obtain the solution. The rule number used for the transformation is given above next to the arrow. The rules definitions used are listed below.
\(\displaystyle \int \frac {\tan ^2(x)}{a+b \cos (x)} \, dx\) |
\(\Big \downarrow \) 3042 |
\(\displaystyle \int \frac {1}{\tan \left (x-\frac {\pi }{2}\right )^2 \left (a-b \sin \left (x-\frac {\pi }{2}\right )\right )}dx\) |
\(\Big \downarrow \) 3202 |
\(\displaystyle \int \frac {\left (1-\cos ^2(x)\right ) \sec ^2(x)}{a+b \cos (x)}dx\) |
\(\Big \downarrow \) 3042 |
\(\displaystyle \int \frac {1-\sin \left (x+\frac {\pi }{2}\right )^2}{\sin \left (x+\frac {\pi }{2}\right )^2 \left (a+b \sin \left (x+\frac {\pi }{2}\right )\right )}dx\) |
\(\Big \downarrow \) 3535 |
\(\displaystyle \frac {\int -\frac {(b+a \cos (x)) \sec (x)}{a+b \cos (x)}dx}{a}+\frac {\tan (x)}{a}\) |
\(\Big \downarrow \) 25 |
\(\displaystyle \frac {\tan (x)}{a}-\frac {\int \frac {(b+a \cos (x)) \sec (x)}{a+b \cos (x)}dx}{a}\) |
\(\Big \downarrow \) 3042 |
\(\displaystyle \frac {\tan (x)}{a}-\frac {\int \frac {b+a \sin \left (x+\frac {\pi }{2}\right )}{\sin \left (x+\frac {\pi }{2}\right ) \left (a+b \sin \left (x+\frac {\pi }{2}\right )\right )}dx}{a}\) |
\(\Big \downarrow \) 3480 |
\(\displaystyle \frac {\tan (x)}{a}-\frac {\frac {\left (a^2-b^2\right ) \int \frac {1}{a+b \cos (x)}dx}{a}+\frac {b \int \sec (x)dx}{a}}{a}\) |
\(\Big \downarrow \) 3042 |
\(\displaystyle \frac {\tan (x)}{a}-\frac {\frac {\left (a^2-b^2\right ) \int \frac {1}{a+b \sin \left (x+\frac {\pi }{2}\right )}dx}{a}+\frac {b \int \csc \left (x+\frac {\pi }{2}\right )dx}{a}}{a}\) |
\(\Big \downarrow \) 3138 |
\(\displaystyle \frac {\tan (x)}{a}-\frac {\frac {2 \left (a^2-b^2\right ) \int \frac {1}{(a-b) \tan ^2\left (\frac {x}{2}\right )+a+b}d\tan \left (\frac {x}{2}\right )}{a}+\frac {b \int \csc \left (x+\frac {\pi }{2}\right )dx}{a}}{a}\) |
\(\Big \downarrow \) 218 |
\(\displaystyle \frac {\tan (x)}{a}-\frac {\frac {b \int \csc \left (x+\frac {\pi }{2}\right )dx}{a}+\frac {2 \left (a^2-b^2\right ) \arctan \left (\frac {\sqrt {a-b} \tan \left (\frac {x}{2}\right )}{\sqrt {a+b}}\right )}{a \sqrt {a-b} \sqrt {a+b}}}{a}\) |
\(\Big \downarrow \) 4257 |
\(\displaystyle \frac {\tan (x)}{a}-\frac {\frac {2 \left (a^2-b^2\right ) \arctan \left (\frac {\sqrt {a-b} \tan \left (\frac {x}{2}\right )}{\sqrt {a+b}}\right )}{a \sqrt {a-b} \sqrt {a+b}}+\frac {b \text {arctanh}(\sin (x))}{a}}{a}\) |
-(((2*(a^2 - b^2)*ArcTan[(Sqrt[a - b]*Tan[x/2])/Sqrt[a + b]])/(a*Sqrt[a - b]*Sqrt[a + b]) + (b*ArcTanh[Sin[x]])/a)/a) + Tan[x]/a
3.1.12.3.1 Defintions of rubi rules used
Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(Rt[a/b, 2]/a)*ArcTan[x/R t[a/b, 2]], x] /; FreeQ[{a, b}, x] && PosQ[a/b]
Int[((a_) + (b_.)*sin[Pi/2 + (c_.) + (d_.)*(x_)])^(-1), x_Symbol] :> With[{ e = FreeFactors[Tan[(c + d*x)/2], x]}, Simp[2*(e/d) Subst[Int[1/(a + b + (a - b)*e^2*x^2), x], x, Tan[(c + d*x)/2]/e], x]] /; FreeQ[{a, b, c, d}, x] && NeQ[a^2 - b^2, 0]
Int[((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)])^(m_)/tan[(e_.) + (f_.)*(x_)]^2, x_Symbol] :> Int[(a + b*Sin[e + f*x])^m*((1 - Sin[e + f*x]^2)/Sin[e + f*x]^ 2), x] /; FreeQ[{a, b, e, f, m}, x] && NeQ[a^2 - b^2, 0]
Int[((A_.) + (B_.)*sin[(e_.) + (f_.)*(x_)])/(((a_.) + (b_.)*sin[(e_.) + (f_ .)*(x_)])*((c_.) + (d_.)*sin[(e_.) + (f_.)*(x_)])), x_Symbol] :> Simp[(A*b - a*B)/(b*c - a*d) Int[1/(a + b*Sin[e + f*x]), x], x] + Simp[(B*c - A*d)/ (b*c - a*d) Int[1/(c + d*Sin[e + f*x]), x], x] /; FreeQ[{a, b, c, d, e, f , A, B}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 - b^2, 0] && NeQ[c^2 - d^2, 0]
Int[((a_.) + (b_.)*sin[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*sin[(e_.) + (f_.)*(x_)])^(n_)*((A_.) + (C_.)*sin[(e_.) + (f_.)*(x_)]^2), x_Symbol] :> Simp[(-(A*b^2 + a^2*C))*Cos[e + f*x]*(a + b*Sin[e + f*x])^(m + 1)*((c + d*S in[e + f*x])^(n + 1)/(f*(m + 1)*(b*c - a*d)*(a^2 - b^2))), x] + Simp[1/((m + 1)*(b*c - a*d)*(a^2 - b^2)) Int[(a + b*Sin[e + f*x])^(m + 1)*(c + d*Sin [e + f*x])^n*Simp[a*(m + 1)*(b*c - a*d)*(A + C) + d*(A*b^2 + a^2*C)*(m + n + 2) - (c*(A*b^2 + a^2*C) + b*(m + 1)*(b*c - a*d)*(A + C))*Sin[e + f*x] - d *(A*b^2 + a^2*C)*(m + n + 3)*Sin[e + f*x]^2, x], x], x] /; FreeQ[{a, b, c, d, e, f, A, C, n}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 - b^2, 0] && NeQ[c^2 - d^2, 0] && LtQ[m, -1] && ((EqQ[a, 0] && IntegerQ[m] && !IntegerQ[n]) || !(IntegerQ[2*n] && LtQ[n, -1] && ((IntegerQ[n] && !IntegerQ[m]) || EqQ[a, 0])))
Int[csc[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-ArcTanh[Cos[c + d*x]]/d, x] /; FreeQ[{c, d}, x]
Time = 0.64 (sec) , antiderivative size = 100, normalized size of antiderivative = 1.64
method | result | size |
default | \(-\frac {1}{a \left (\tan \left (\frac {x}{2}\right )-1\right )}+\frac {b \ln \left (\tan \left (\frac {x}{2}\right )-1\right )}{a^{2}}-\frac {1}{a \left (\tan \left (\frac {x}{2}\right )+1\right )}-\frac {b \ln \left (\tan \left (\frac {x}{2}\right )+1\right )}{a^{2}}+\frac {2 \left (-a^{2}+b^{2}\right ) \arctan \left (\frac {\left (a -b \right ) \tan \left (\frac {x}{2}\right )}{\sqrt {\left (a -b \right ) \left (a +b \right )}}\right )}{a^{2} \sqrt {\left (a -b \right ) \left (a +b \right )}}\) | \(100\) |
risch | \(\frac {2 i}{a \left ({\mathrm e}^{2 i x}+1\right )}-\frac {b \ln \left ({\mathrm e}^{i x}+i\right )}{a^{2}}+\frac {b \ln \left ({\mathrm e}^{i x}-i\right )}{a^{2}}-\frac {\sqrt {-a^{2}+b^{2}}\, \ln \left ({\mathrm e}^{i x}-\frac {i \sqrt {-a^{2}+b^{2}}-a}{b}\right )}{a^{2}}+\frac {\sqrt {-a^{2}+b^{2}}\, \ln \left ({\mathrm e}^{i x}+\frac {i \sqrt {-a^{2}+b^{2}}+a}{b}\right )}{a^{2}}\) | \(134\) |
-1/a/(tan(1/2*x)-1)+b/a^2*ln(tan(1/2*x)-1)-1/a/(tan(1/2*x)+1)-b/a^2*ln(tan (1/2*x)+1)+2/a^2*(-a^2+b^2)/((a-b)*(a+b))^(1/2)*arctan((a-b)*tan(1/2*x)/(( a-b)*(a+b))^(1/2))
Time = 0.30 (sec) , antiderivative size = 203, normalized size of antiderivative = 3.33 \[ \int \frac {\tan ^2(x)}{a+b \cos (x)} \, dx=\left [-\frac {b \cos \left (x\right ) \log \left (\sin \left (x\right ) + 1\right ) - b \cos \left (x\right ) \log \left (-\sin \left (x\right ) + 1\right ) - \sqrt {-a^{2} + b^{2}} \cos \left (x\right ) \log \left (\frac {2 \, a b \cos \left (x\right ) + {\left (2 \, a^{2} - b^{2}\right )} \cos \left (x\right )^{2} + 2 \, \sqrt {-a^{2} + b^{2}} {\left (a \cos \left (x\right ) + b\right )} \sin \left (x\right ) - a^{2} + 2 \, b^{2}}{b^{2} \cos \left (x\right )^{2} + 2 \, a b \cos \left (x\right ) + a^{2}}\right ) - 2 \, a \sin \left (x\right )}{2 \, a^{2} \cos \left (x\right )}, -\frac {b \cos \left (x\right ) \log \left (\sin \left (x\right ) + 1\right ) - b \cos \left (x\right ) \log \left (-\sin \left (x\right ) + 1\right ) + 2 \, \sqrt {a^{2} - b^{2}} \arctan \left (-\frac {a \cos \left (x\right ) + b}{\sqrt {a^{2} - b^{2}} \sin \left (x\right )}\right ) \cos \left (x\right ) - 2 \, a \sin \left (x\right )}{2 \, a^{2} \cos \left (x\right )}\right ] \]
[-1/2*(b*cos(x)*log(sin(x) + 1) - b*cos(x)*log(-sin(x) + 1) - sqrt(-a^2 + b^2)*cos(x)*log((2*a*b*cos(x) + (2*a^2 - b^2)*cos(x)^2 + 2*sqrt(-a^2 + b^2 )*(a*cos(x) + b)*sin(x) - a^2 + 2*b^2)/(b^2*cos(x)^2 + 2*a*b*cos(x) + a^2) ) - 2*a*sin(x))/(a^2*cos(x)), -1/2*(b*cos(x)*log(sin(x) + 1) - b*cos(x)*lo g(-sin(x) + 1) + 2*sqrt(a^2 - b^2)*arctan(-(a*cos(x) + b)/(sqrt(a^2 - b^2) *sin(x)))*cos(x) - 2*a*sin(x))/(a^2*cos(x))]
\[ \int \frac {\tan ^2(x)}{a+b \cos (x)} \, dx=\int \frac {\tan ^{2}{\left (x \right )}}{a + b \cos {\left (x \right )}}\, dx \]
Exception generated. \[ \int \frac {\tan ^2(x)}{a+b \cos (x)} \, dx=\text {Exception raised: ValueError} \]
Exception raised: ValueError >> Computation failed since Maxima requested additional constraints; using the 'assume' command before evaluation *may* help (example of legal syntax is 'assume(4*b^2-4*a^2>0)', see `assume?` f or more de
Leaf count of result is larger than twice the leaf count of optimal. 111 vs. \(2 (51) = 102\).
Time = 0.33 (sec) , antiderivative size = 111, normalized size of antiderivative = 1.82 \[ \int \frac {\tan ^2(x)}{a+b \cos (x)} \, dx=-\frac {b \log \left ({\left | \tan \left (\frac {1}{2} \, x\right ) + 1 \right |}\right )}{a^{2}} + \frac {b \log \left ({\left | \tan \left (\frac {1}{2} \, x\right ) - 1 \right |}\right )}{a^{2}} + \frac {2 \, {\left (\pi \left \lfloor \frac {x}{2 \, \pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\left (-2 \, a + 2 \, b\right ) + \arctan \left (-\frac {a \tan \left (\frac {1}{2} \, x\right ) - b \tan \left (\frac {1}{2} \, x\right )}{\sqrt {a^{2} - b^{2}}}\right )\right )} \sqrt {a^{2} - b^{2}}}{a^{2}} - \frac {2 \, \tan \left (\frac {1}{2} \, x\right )}{{\left (\tan \left (\frac {1}{2} \, x\right )^{2} - 1\right )} a} \]
-b*log(abs(tan(1/2*x) + 1))/a^2 + b*log(abs(tan(1/2*x) - 1))/a^2 + 2*(pi*f loor(1/2*x/pi + 1/2)*sgn(-2*a + 2*b) + arctan(-(a*tan(1/2*x) - b*tan(1/2*x ))/sqrt(a^2 - b^2)))*sqrt(a^2 - b^2)/a^2 - 2*tan(1/2*x)/((tan(1/2*x)^2 - 1 )*a)
Time = 14.26 (sec) , antiderivative size = 77, normalized size of antiderivative = 1.26 \[ \int \frac {\tan ^2(x)}{a+b \cos (x)} \, dx=\frac {2\,\mathrm {atanh}\left (\frac {\sin \left (\frac {x}{2}\right )\,\sqrt {b^2-a^2}}{a\,\cos \left (\frac {x}{2}\right )+b\,\cos \left (\frac {x}{2}\right )}\right )\,\sqrt {b^2-a^2}}{a^2}-\frac {2\,b\,\mathrm {atanh}\left (\frac {\sin \left (\frac {x}{2}\right )}{\cos \left (\frac {x}{2}\right )}\right )}{a^2}+\frac {\sin \left (x\right )}{a\,\cos \left (x\right )} \]